package pratice.fengzhongye.interview;

import org.junit.Test;

/**
 * 面试题：考察& 和 | 运算符
 *
 * @author 吴宇亮 on 2019/2/19 0019 12:53
 */
public class Lesson9_operator {

    @Test
    public void test(){
        int a = 2, b = 3;
        if( a==1 && ((b = 4) == 5) ){
            System.out.println("invoked!");
        }
        System.out.println(a);
        System.out.println(b);
    }

    @Test
    public void test2(){
        int a = 2, b = 3;
        if( a==1 & ((b = 4) == 5) ){ //此时&为逻辑运算符, 但是没有短路特性
            System.out.println("invoked!");
        }
        System.out.println(a);
        System.out.println(b);
    }

    @Test
    public void test3(){
        int a = 2, b = 5; //a=010, b=101
        System.out.println(a & b); //此时&为按位与算数运算符, 结果为0
    }

}
